<!DOCTYPE html >
<html xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>确认</title>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <script th:src="@{/layui/layui.js}"></script>
    <!--    一定需要引入这个包-->
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>

</head>
<body  >
<!--<div id="container"></div>-->

<!--<div class='info' style='min-width:15rem;'>可拖动Marker调整位置</div>-->

<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=978aa979b2608cf1c202b3402509ebba"></script>
<script >



    function get() {
        var mylocation_a=$("#mylocation_a").val();
        var mylocation_b=$("#mylocation_b").val();
        var required_a=$("#required_a").val();
        var required_b=$("#required_b").val();
        var distance=$("#distance").val();

        var tea_id=$("#tea_id").val();
        var tea_name=$("#tea_name").val();
        var class_id=$("#class_id").val();
        var tea_map_id=$("#tea_map_id").val();
        var status;

        var A=new AMap.LngLat(mylocation_a, mylocation_b);
        var B=new AMap.LngLat(required_a, required_b);
        var remote=Math.round(A.distance(B));
        if (remote<distance)
        {
            status=1;

        }else {
            status = 0;
        }
        console.log(status)
            $.post(
                '/stu/map/confirm/addsubmit',
                {'tea_id':tea_id,'tea_name':tea_name,'status':status,'class_id':class_id,'tea_map_id':tea_map_id},
                function (result) {
                    if(status==1)
                    alert("签到成功");
                    else if(status==0)
                        alert("签到失败:原因1：要求范围："+distance+"米，但是你离目的地："+remote+"米--原因2：签到已经超时");
                    //刷新页面
                    location.href = '/stu/map/show';
                }
            )
    }


</script>
<div class="layui-container">
    <input type="hidden" id="mylocation_a"  th:value="${mylocation_a}" >
    <input type="hidden" id="mylocation_b"  th:value="${mylocation_b}" >
    <input type="hidden" id="required_a"  th:value="${required_a}" >
    <input type="hidden" id="required_b"  th:value="${required_b}" >
    <input type="hidden" id="class_id" th:value="${map.getClass_id()}">
    <input type="hidden" id="tea_map_id" th:value="${tea_map_id}">
    <input type="hidden" id="distance"  th:value="${distance}" >
    <input type="hidden" id="tea_id" th:value="${map.getTea_id()}">
    <input type="hidden"  id="tea_name" th:value="${map.getTea_name()}"   >


    <br>
    <button class="layui-btn" onclick="get()" >再次确认提交</button>




</div>









</body>
</html>